<template>
  <div>
    <el-carousel :interval="4000" type="card" height="360px">
      <el-carousel-item v-for="item in sliders" :key="item._id" >
        <img :src="item.url" class="banner" />
      </el-carousel-item>
    </el-carousel>
  </div>
</template>

<script>
// @ is an alias to /src
import { mapActions, mapState } from 'vuex';
import { SET_SLIDERS } from '@/store/action.types';

export default {
  name: 'home',
  computed: {
    ...mapState(['sliders']),
  },
  methods: {
    ...mapActions([SET_SLIDERS]),
  },
  mounted() {
    if (!this.sliders.length) {
      this[SET_SLIDERS]();
    }
  },
};
</script>
<style lang="scss" scoped>
.banner{
  width: 100%;
  height: 100%;
}
</style>
